<?php include('includes/start_session.php') ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
	<title>e-class advanced_search</title>
	
	<link href="styles/site.css" type="text/css" rel="stylesheet" />
</head>
<body>
	<?php include('includes/header.php') ?>
	<div id="content" class="content_padding">
		<form action="search.php?action=advanced_search" method="post">
			<table class="big_table">
				<tr>
					<td colspan="2">
						<h2>Σύνθετη Αναζήτηση</h2>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<b>Συμπληρώστε όσα πεδία θέλετε</b>
					</td>
				</tr>
				<tr>
					<td>
						<span>Όνομα μαθήματος:</span>
					</td>
					<td>
						<input type="text" name="course" />
					</td>
				</tr>
				<tr>
					<td>
						<span>Όνομα καθηγητή:</span>
					</td>
					<td>
						<input type="text" name="professor" />
					</td>
				</tr>
				<tr>
					<td>
						<span>Κατηγορία μαθήματος:</span>
					</td>
					<td>
						<select name="category">
							<optgroup label="Όλες">
								<option value="all">Όλες</option>
							</optgroup>
							<?php
								include('db-api/txt-db-api.php');
								
								$db = new Database('Eclass');
								$categories = $db->executeQuery('SELECT Name FROM Categories');
								while($categories->next())
								{
									list($cat) = $categories->getCurrentValues();
									echo '<optgroup label="' . $cat . '">';
									$subcategories = $db->executeQuery('SELECT Name FROM SubCategories WHERE ' .
										'CategoryName = \'' . $cat . '\'');
									while($subcategories->next())
									{
										list($subcat) = $subcategories->getCurrentValues();
										echo '<option value="' . $subcat . '">' . $subcat . '</option>';
									}
									echo '</optgroup>';
								}
							?>
						</select>
					</td>
				</tr>
				<tr>
					<td class="right_align" colspan="2">
						<input type="submit" value="Αναζήτηση" />
					</td>
				</tr>
			</table>
		</form>
	</div>
	<?php include('includes/footer.php') ?>
</body>
</html>
